package ca.newcommerce.youtube.data
{
    import ca.newcommerce.youtube.iterators.*;

    public class VideoData extends AbstractData
    {
        protected var _data:Object;

        public function VideoData(param1:Object)
        {
            this._data = param1;
            return;
        }// end function

        public function get links() : LinkIterator
        {
            return new LinkIterator(this._data.link);
        }// end function

        public function get id() : String
        {
            return fromObj(this._data, "id");
        }// end function

        public function get duration() : Number
        {
            return this.media.duration;
        }// end function

        public function get media() : MediaGroupData
        {
            return new MediaGroupData(this._data.media$group);
        }// end function

        public function get authors() : AuthorIterator
        {
            return new AuthorIterator(this._data.author);
        }// end function

        public function get viewCount() : Number
        {
            return parseInt(this._data.yt$statistics.viewCount);
        }// end function

        public function get categorywords() : Array
        {
            return this.categories.categorywords;
        }// end function

        public function get swfUrl() : String
        {
            var _loc_1:MediaContentData = null;
            var _loc_2:* = this.media.contents;
            do
            {
                
                if (_loc_1.type == "application/x-shockwave-flash")
                {
                    return _loc_1.url;
                }
                var _loc_3:* = _loc_2.next();
                _loc_1 = _loc_2.next();
            }while (_loc_3)
            return "";
        }// end function

        public function get published() : String
        {
            return fromObj(this._data, "published");
        }// end function

        public function get commentFeedUri() : String
        {
            if (this._data.gd$comments && this._data.gd$comments.gd$feedLink && this._data.gd$comments.gd$feedLink.href)
            {
                return this._data.gd$comments.gd$feedLink.href;
            }
            return null;
        }// end function

        public function get actualId() : String
        {
            var _loc_1:* = this.id;
            return _loc_1.substr((_loc_1.lastIndexOf("/") + 1));
        }// end function

        public function get keywords() : Array
        {
            return this.categories.keywords;
        }// end function

        public function get mobileUrl() : String
        {
            var _loc_1:MediaContentData = null;
            var _loc_2:* = this.media.contents;
            do
            {
                
                if (_loc_1.type == "video/3gpp" && _loc_1.format == 6)
                {
                    return _loc_1.url;
                }
                var _loc_3:* = _loc_2.next();
                _loc_1 = _loc_2.next();
            }while (_loc_3)
            return "";
        }// end function

        public function get commentCount() : Number
        {
            if (this._data.gd$comments && this._data.gd$comments.gd$feedLink && this._data.gd$comments.gd$feedLink.countHint)
            {
                return parseInt(this._data.gd$comments.gd$feedLink.countHint);
            }
            return 0;
        }// end function

        public function get title() : String
        {
            return fromObj(this._data, "title");
        }// end function

        public function get content() : String
        {
            return fromObj(this._data, "content");
        }// end function

        public function get updated() : String
        {
            return fromObj(this._data, "updated");
        }// end function

        public function get categories() : CategoryIterator
        {
            return new CategoryIterator(this._data.category);
        }// end function

        public function get rating() : RatingData
        {
            return new RatingData(this._data.gd$rating);
        }// end function

    }
}
